package com.atXiao.demo;

import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class Good implements Comparable {

    public String name;
    public double price;


    @Override
    public int compareTo(Object o) {
        if (o instanceof Good) {
           Good g1 = (Good) o;
            if (this.getName().equals(g1.getName())) {
                return -Double.compare(this.getPrice(), g1.getPrice());
            }
        }
        throw new RuntimeException("数据类型不一致");
    }
}
